//这里把一些全局需要的namespace初始化
HW.App.run(function($helper, $request){
    $helper.init();
    $request.init();
});

HW.App.run(function ($ionicPlatform, $rootScope, $state) {
    $ionicPlatform.ready(function () {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        }
        if (window.StatusBar) {
            StatusBar.styleDefault();
        }
    });

    //添加全局控制逻辑，控制tabs是否隐藏
    $rootScope.$on('$ionicView.beforeEnter', function() {
        $rootScope.hideTabs = $state.current.hideTab || false;
    });
});

HW.App.config(function($stateProvider, $urlRouterProvider){

    $stateProvider.state('tab', {
        url : '/tab',
        abstract : true,
        templateUrl : 'tpl/tab.html'
    }).state('tab.home', {
        url : '/home',
        views : {
            'tab-home' : {
                templateUrl : 'home.html',
                controller : 'MainCtrl'
            }
        }
    }).state('tab.person', {
        url : '/person',
        views : {
            'tab-person' : {
                templateUrl : 'person.html',
                controller : 'PersonCtrl'
            }
        }
    }).state('tab.person-changepassword', {
        url : '/person/changepassword',
        views : {
            'tab-person': {
                templateUrl: 'tpl/person_change_password.html',
                controller: 'PersonCtrl'
            }
        },
        hideTab : true
    }).state('tab.person-baseinfo', {
        url : '/person/baseinfo',
        hideTab : true,
        views : {
            'tab-person' : {
                templateUrl : 'tpl/person_base_info.html',
                controller : 'PersonCtrl'
            }
        }
    });


    $stateProvider.state('tab.home-secondcategory', {
        url : '/home/secondcategory/:cid',
        hideTab : true,
        views : {
            'tab-home' : {
                templateUrl : 'tpl/second_category.html',
                controller : 'SecondCategoryCtrl'
            }
        }
    });



    //$urlRouterProvider.otherwise('/tab/home');
});